<!DOCTYPE html>
<!--
Copyright 2014 Google Inc.  All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License.  You may obtain a copy
of the License at: http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distrib-
uted under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
OR CONDITIONS OF ANY KIND, either express or implied.  See the License for
specific language governing permissions and limitations under the License.
-->
<title></title>
<script src="../../../../testing/puppet/puppet.js"></script>
<script src="../../../../testing/puppet/google.js"></script>
<script src="main.js"></script>
<script>
var tileSrc = 'mw1.google.com/crisisresponse/2011/philippines_flooding/'
              'geoeye/Philippines_PO_765484_2011_08_23_2011_12_28_maptiles/';

window.onload = function() {
  // Turn on just the tile layer, which has min_zoom 4, max_zoom 18.
  runTest('/crisismap/.maps/2?&layers=1319673871167&ll=8.3,124.65&z=4',
          crisis.tab.tabbar.layers, testMapZoom);
};

function testMapZoom(isTabbed) {
 // To work around a mysterious IE8 phenomenon where the map center's latitude
  // is shifted after loading, re-center the map before zooming.
  var tileLayer = crisis.getLayerPaths(1, isTabbed);
  if (puppet.userAgent.isIE(8)) {
    run(shown, tileLayer.zoomToArea);
    run(click, tileLayer.zoomToArea);
  }

  // At zoom level 4, the layer should be shown.
  run(function() { theMap.setZoom(4); });
  run(count(shown, 1, null), crisis.tile(tileSrc));

  // At zoom level 3, the layer should not be shown.
  run(function() { theMap.setZoom(3); });
  run(count(shown, 0), crisis.tile(tileSrc));

  // At zoom level 18, the layer should be shown.
  run(function() { theMap.setZoom(18); });
  run(count(shown, 1, null), crisis.tile(tileSrc));

  // At zoom level 19, the layer should not be shown.
  run(function() { theMap.setZoom(19); });
  run(count(shown, 0), crisis.tile(tileSrc));
}
</script>
